# -*- coding:utf-8 -*-

import requests
from bs4 import BeautifulSoup


def wbrs(num=10):
    if(num):
        num = int(num)
    else:
        num = 10
    print(num)
    headers = {
        'cookie': 'SUBP=0033WrSXqPxfM72-Ws9jqgMF55529P9D9W5JVORQz2WjjMucpnryn4Eu; _s_tentry=passport.weibo.com; Apache=8054486237377.8955.1667271424101; SINAGLOBAL=8054486237377.8955.1667271424101; ULV=1667271424312:1:1:1:8054486237377.8955.1667271424101:; SUB=_2AkMUPUXIf8NxqwFRmPwWzWngZI5_zAzEieKiYbQTJRMxHRl-yT9jqhFatRB6P71rJ5PMXQQd5lL80akrFINyjIHiv7xx; UOR=,,www.baidu.com; PC_TOKEN=423f113114'
    }
    # realtimehot socialevent  entrank
    html = requests.get(url='https://s.weibo.com/top/summary?cate=realtimehot',headers=headers)
    page_text = html.text
    # print(page_text)
    soup = BeautifulSoup(page_text, 'html.parser')
    table = soup.select('table td > a')
    # table = tree.xpath("//table/tbody/tr/td/a")
    rstr = ""
    i = 0
    for a in table:
        if(i==num):
            break
        rstr = rstr+"#"+a.get_text()+"\n"
        i = i+1
    print(rstr)
    return rstr

if __name__ == '__main__':
    wbrs("10")
